﻿CREATE PROCEDURE [dbo].[kp_GetNextMaBienNhanHKD]	
	@Ma_LoaiHs nvarchar(15),
	@Ma_Hs int
AS
Begin
	Declare @So_Bn_Ht int,@Nam_Ht int
	update tblDmStt set  So_Bn_Ht=So_Bn_Ht+1
	Select @So_Bn_Ht=So_Bn_Ht,@Nam_Ht=Nam_Ht from tblDmStt
	if @Nam_Ht <> DatePart(year,getdate())
	begin
		set @Nam_Ht=DatePart(year,getdate())
		set @So_Bn_Ht=1
		update tblDmStt set So_Bn_Ht=@So_Bn_Ht, Nam_Ht=@Nam_Ht
	end
	--{0}-HKD/{1}
	select 	cast(So_Bn_Ht as nvarchar(10))+'-HKD/'+Cast(Nam_Ht as nvarchar(10)) from tblDmStt
end
RETURN 0;